def read1(input_file1):
    lines = open(input_file1).readlines()
    target = []
    for i in range(len(lines)):
        n = []
        m = lines[i].split()
        for j in m:
            a = j.split("\\")[0]
            b = j.split("\\")[1]
            if b == "B" or b == "I":
                n.append(a)
        target.append(n)
    return target


def write(input_file1, output_file_1):
    target = read1(input_file1)
    fp = open(output_file_1, 'w')
    for seg in range(len(target)):
        for seg1 in range(len(target[seg])):
            if seg1 == len(target[seg])-1:
                fp.write(target[seg][seg1])
            else:
                fp.write(target[seg][seg1] + " ")
        fp.write("\n")


if __name__ == "__main__":
    file1 = 'data/16res/target_test_1.txt'
    file2 = 'data/16res/generate_target_test.txt'
    # read1(file1)
    write(file1, file2)
